var ns, toast, actionsheet, UIAlbumBrowser;
var app = new Vue({
    el: '#app',
    data: {
       List:[],
       showsearch:false,
       activeStatus:-1,
    },
    methods: {
        get_data:function(){
            var that=this;
            that.List=[];
            var option={};
            option.Status=that.activeStatus;
            option.action='loadsaleactivitydatagrid';
            console.log(JSON.stringify(option));
            ns.post(option, function(succeed, data, err) {
                // console.log(JSON.stringify(succeed));
                console.log(JSON.stringify(data));
                // console.log(JSON.stringify(err));
                if(succeed){
                    that.List=data.rows;
                }else{
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    }); 
                }
                
            });


        },

        //活动内容
        do_openhuodong:function(id,Status){
            var that=this;
            ns.openWin('activity_detail', '活动内容',{
                id:id,
                Status:Status
            });
        },
        //添加新活动
        do_addactive:function(){
            var that=this;
            ns.openWin('activity_add', '新增营销活动');
        },
        doClickStatus:function(type){
            var that=this;
            that.activeStatus=type;
            that.showsearch=false;
            that.get_data();
        },
    }
       


      
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    // toast = new auiToast();
    // actionsheet = new auiActionsheet();
    UIAlbumBrowser = api.require('UIAlbumBrowser');
    app.get_data();
    api.addEventListener({
        name: 'do_open_saixuan'
    }, function(ret, err) {
        app.showsearch=true;
    });
    api.addEventListener({
        name: 'load_active'
    }, function(ret, err) {
        app.get_data();
    });


};
